package com.example.demo.enumCorrelation;

/**
 * create by Chas_tsj
 * 2024/8/22 13:54:02
 **/

public class EnumCorrelation {
    //    public static void main(String[] args) {
//        Color color = Color.GREEN;
//        switch (color) {
//            case RED:
//                System.out.println("red");
//            default:
//                System.out.println("default");
//        }
//    }
//    public static void main(String[] args) {
//        System.out.println(DayOfWeek.SATURDAY.isWeekDay());
//    }
//    public static void main(String[] args) {
//        System.out.println(Shape.CIRCLE.getCode());
//        Color[] colors = Color.values();
//        for (Color color : colors) {
//            System.out.println(color);
//        }
//    }
//    public static void main(String[] args) {
//        ThreadSafeCounter.INSTANCE.increment();
//        ThreadSafeCounter.INSTANCE.increment();
//        System.out.println(ThreadSafeCounter.INSTANCE.getCount());
//        Color.RED.printColor();
//        for(Color color : Color.values()){
//            System.out.println(color);
//        }
//        for(Shape shape : Shape.values()){
//            System.out.println(shape);
//            System.out.println(shape.getCode());
//        }
//    }
    public static void main(String[] args) {
        Weekday day = Weekday.MONDAY;
        System.out.println(day.getDayOfWeek());
        for(UserStatus ins:UserStatus.values()){
            System.out.println(ins.getCode()+"/"+ins.getInfo());
        }
    }
}

enum Color {
    RED, GREEN, BLUE;
    public void printColor(){
        System.out.println(this.name());
    }
}

enum DayOfWeek {
    MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;

    public boolean isWeekDay() {
        return this != SATURDAY && this != SUNDAY;
    }
}

enum Shape {
    CIRCLE(0), SQUARE(1), RECTANGLE(2);
    int code;

    Shape(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }
}
enum ThreadSafeCounter {
    INSTANCE;

    private int count = 0;

    public synchronized void increment() {
        count++;
    }

    public synchronized int getCount() {
        return count;
    }
}
 enum Weekday {
    MONDAY(1),
    TUESDAY(2),
    WEDNESDAY(3),
    THURSDAY(4),
    FRIDAY(5),
    SATURDAY(6),
    SUNDAY(7);

    private int dayOfWeek;

    // 构造函数为私有以防止外部实例化
    private Weekday(int dayOfWeek) {
        this.dayOfWeek = dayOfWeek;
    }

    public int getDayOfWeek() {
        return dayOfWeek;
    }
}
enum UserStatus{
    OK(0,"正常"),
    DISABLE(1,"禁用"),
    LOCKED(2,"锁定");
    int code;
    String info;
    UserStatus(int code,String info){
        this.code=code;
        this.info=info;
    }
    public int getCode(){
        return this.code;
    }
    public String getInfo(){
        return this.info;
    }
}